package com.fourth.utils;

/**
 * @Author CZQ
 * @Date 2022/7/31 14:50
 * @Version 1.0
 */
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class JedisPoolUtil {
    private static JedisPool jedisPool;

    private static void initJedisPool() {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(100);
        poolConfig.setMaxIdle(5);
        poolConfig.setMinIdle(5);
        poolConfig.setBlockWhenExhausted(true);
        poolConfig.setMaxWaitMillis(2000);
        poolConfig.setTestOnBorrow(true);
        jedisPool = new JedisPool(poolConfig,"hadoop103",6379,10000);
    }

    public static JedisPool getJedisPool(){
        if(jedisPool == null){
            initJedisPool();
        }
        return jedisPool;
    }
}
